<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/2
 * Time: 18:23
 */

namespace app\admin\controller;


use app\admin\model\UnionInfo;
use think\Controller;
use app\admin\model\Union as UnionModel;
class Union  extends Index
{

    public function index()
    {
        return view();
    }

    public function indexData()
    {
        $unionModel = new UnionModel();
        $data = $unionModel -> indexData();
        return json($data);
    }

    //工会收益二维码
    public function unionProfitDetail()
    {
        $unionModel = new UnionModel();
        $union_id = input('union_id');
        $unionInfo = $unionModel->where('id',$union_id)->find();
        $unionInfo['name'] = preg_replace_callback('/@E(.{6}==)/', function ($r) {
            return base64_decode($r[1]);
        }, $unionInfo['name']);
        get_QR_code($unionInfo);
        add_ch_QR_Code($unionInfo);
        return view()->assign('unionInfo',$unionInfo);
    }

    //同意开通工会
    public function unionAgree()
    {
        $unionModel = new UnionModel();
        $res = $unionModel->unionAgree();
        return $res;
    }
    //拒绝开通工会
    public function unionRefuse()
    {
        $unionModel = new UnionModel();
        $res = $unionModel->unionRefuse();
        return $res;
    }
    //检测用户信息
    public function unionCheckInfo()
    {
        $union_id = input('union_id');
        $unionInfoModel = new UnionInfo();
        $data = $unionInfoModel->field('*,FROM_UNIXTIME(create_time) as create_time')->where('union_id',$union_id)->find();
        return view()->assign('data',$data);
    }

}